import Vue from 'vue'
import Vuex from 'vuex'
import user from './user/user.js'

Vue.use(Vuex)
const store = new Vuex.Store({
  state: {
    count: 100
  },
  mutations: {
    addCount (state, count) {
      state.count += count
    },
    removeCount (state, count) {
      state.count -= count
    },
    changeCount (state, count) {
      state.count = count
    }
  },
  actions: {
    removeCountAction (context, count) {
      setTimeout(() => {
        context.commit('removeCount', count)
      }, 2000)
    }
  },
  modules: {
    user
  }
})

export default store
